//
// Created by 123 on 2025/1/9.
//
#include "iostream"

#include "vector"
#include "string"
#include "map"
#include "ctime"
using namespace std;


#define CEHUA 0
#define MEISHU 1
#define YANFA 2

class Worker{
public:
    string name;
    int salary;
};

void createWorker(vector<Worker>& v){
   string nameSeed = "ABCDEFGHIJ";
    for (int i = 0; i < 10; ++i) {
        Worker worker;
        worker.name = "员工";
        worker.name += nameSeed[i];
        worker.salary = rand()%10000+10000;
        v.push_back(worker);
    }
}

void setGroup(vector<Worker>& v,multimap<int,Worker>& m){
    for(vector<Worker>::iterator it= v.begin();it != v.end();it++){
        //随机产生部门编号
        int deptId = rand()%3;
        //将员工插入到分组 key为部分编号，value为员工
        m.insert(make_pair(deptId,*it));
    }
}

void showDeptGroup(multimap<int,Worker>& m){
    cout << "=====策划部门=====" << endl;
    multimap<int,Worker>::iterator pos = m.find(CEHUA);
    //统计具体人数
    int count = m.count(CEHUA);
    int index = 0;
    for(;pos != m.end() && index < count;pos++,index++){
        cout << "name=" << pos->second.name << " salary:" << pos->second.salary << endl;
    }
    cout << "=====美术部门=====" << endl;
    pos = m.find(MEISHU);
    count = m.count(CEHUA);
    index =0;
    for(;pos != m.end() && index < count;pos++,index++){
        cout << "name=" << pos->second.name << " salary:" << pos->second.salary << endl;
    }


    cout << "=====研发部门=====" << endl;
    pos = m.find(YANFA);
    count = m.count(YANFA);
    index =0;
    for(;pos != m.end() && index < count;pos++,index++){
        cout << "name=" << pos->second.name << " salary:" << pos->second.salary << endl;
    }

}

int main144(){
    srand((unsigned int)time(NULL));
    vector<Worker> vWorker;
    createWorker(vWorker);
    multimap<int,Worker> mWorker;
    setGroup(vWorker,mWorker);
    showDeptGroup(mWorker);
}
